fix: tell a dead sensor apart from one with no data (#1102) - #1107
Open
MOHITKOURAV01 wants to merge 1 commit into
Open
fix: tell a dead sensor apart from one with no data (#1102)#1107MOHITKOURAV01 wants to merge 1 commit into
MOHITKOURAV01 wants to merge 1 commit into
Conversation
The health tiles both read through `||`, so zero and absent collapsed into the same branch. `health_score` is `INTEGER CHECK (0..100)` and `uptime_percentage` is `DECIMAL(5,2)` — zero is legal in both, and it is what a sensor that has dropped out looks like. A sensor at 0% uptime rendered `98.5%` in the same blue as a healthy one, under a heading reading "Uptime (30 Days)". `98.5` is not a placeholder anyone can recognise as a placeholder. readMetric/formatPercentage/getScoreColor now keep the two apart: a real zero renders as zero and colours red, a missing value renders "No data" in grey. The hook also set `loading` on every 30-second poll, and the dashboard early-returns on `loading` — so twice a minute the whole page unmounted, taking the open acknowledgment modal and the resolution notes typed into it with it. `loading` is now the first load only; a refresh sets `refreshing` and updates in place. `error` never got cleared, so one dropped request pinned the dashboard to a red message for the life of the page while the interval carried on succeeding invisibly behind it. It is cleared by the next successful read, shown as a banner over existing data rather than instead of it, and offers a retry. Dropped the optimistic `healthScore + 10` on acknowledge. Acknowledging records that a human saw an alert; it does not repair the sensor, and the next poll took the invented recovery straight back off again.
|
@MOHITKOURAV01 is attempting to deploy a commit to the Aditya Mahajan's projects Team on Vercel. A member of the Team first needs to authorize it. |
Thank You for Your Contribution! 🎉Hi @MOHITKOURAV01, Thank you for opening this Pull Request and contributing to our project. We truly appreciate your efforts.
The maintainer @Aditya8369 will review your PR shortly! Happy Contributing! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1102
sensor_health_scores.health_scoreisINTEGER CHECK (0..100)anduptime_percentageisDECIMAL(5,2). Zero is legal and meaningful in both — it is what a sensor that has dropped out looks like — and both were read through||, which cannot tell zero from absent.The uptime tile was the bad one.
metrics?.uptimePercentage || '98.5'rendered a specific, plausible, reassuring figure in the same blue as a healthy sensor, under a heading reading "Uptime (30 Days)", for both a genuine0.00%and a missing field. Nothing on screen distinguished it from a measurement.What changed
src/components/SensorHealthDashboard.jsx— three small exported helpers do the reading:0--(reads as "no data")0, coloured red--in red--in grey0.0098.5%0%98.5%No data, greyedsrc/hooks/useSensorHealth.js—loadDatasetsetLoading(true)on every 30-second poll, and the dashboard early-returns onloading. So twice a minute the whole component unmounted, taking the open "Acknowledge Alert" modal and the resolution notes typed into it with it. Writing a paragraph of maintenance notes was a race against a timer, and losing it gave no warning.loadingis now the first load only; a refresh setsrefreshingand updates in place.setError(null)appeared nowhere, so one dropped request pinned the dashboard to a red message for the life of the page while the interval carried on succeeding invisibly behind the early return. It is now cleared by the next successful read, rendered as a banner over existing data rather than instead of it, and carries a retry.Dropped the optimistic
healthScore + 10on acknowledge. Acknowledging records that a human saw an alert; it does not repair the sensor, the server is never asked to re-evaluate, and the next poll took the invented recovery straight back off again. Acknowledge three in a row and the dashboard claimed a 30-point recovery that never happened.Also added: a request-id guard so a slow response for the previously selected sensor cannot paint over the current one, a mounted guard, and
window.alertreplaced by the in-page error banner.Tests
23 new tests in
src/components/SensorHealthDashboard.test.jsx, covering the helpers directly and the three behaviours above through the component — including one that types notes into the modal, advances the clock past the poll interval, and asserts the text is still there.Verification
Note:
npm run buildcurrently fails onmainfor two unrelated reasons — a duplicatenextLeveldeclaration inLeaderboard.jsxandframer-motionmissing frompackage.json. Both are raised separately; neither is touched by this branch.